/* GLUCo - OpenGL Unified Code
 * 
 * Copyright (c) 2007 Pedro Leite.
 * 
 * Written by Pedro Leite, <pedro.leite@gmail.com>
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef WINDOW_H
#define WINDOW_H

#include <stdlib.h>
#include <string.h>

#include <GL/glut.h>

#include "util.h"

typedef void (*PFNINITFUNC) (void);
typedef void (*PFNDISPLAYFUNC) (void);
typedef void (*PFNRESHAPEFUNC) (int width, int height);
typedef void (*PFNKEYBOARDFUNC) (unsigned char key_value, int x, int y);
typedef void (*PFNKEYBOARDUPFUNC) (unsigned char key_value, int x, int y);
typedef void (*PFNSPECIALFUNC) (int key_value, int x, int y);
typedef void (*PFNSPECIALUPFUNC) (int key_value, int x, int y);
typedef void (*PFNMOUSEFUNC) (int button, int state, int x, int y);
typedef void (*PFNMOTIONFUNC) (int x, int y);
typedef void (*PFNPASSIVEMOTIONFUNC) (int x, int y);
typedef void (*PFNIDLEFUNC) (void);

typedef struct Window {
	int id;
	unsigned int width;
	unsigned int height;
	unsigned int x_pos;
	unsigned int y_pos;
	bool fullscreen;
	bool visible;
	char* title;

	PFNINITFUNC init_func;
	PFNDISPLAYFUNC display_func;
	PFNRESHAPEFUNC reshape_func;
	PFNKEYBOARDFUNC keyboard_func;
	PFNKEYBOARDUPFUNC keyboard_up_func;
	PFNSPECIALFUNC special_func;
	PFNSPECIALUPFUNC special_up_func;
	PFNMOUSEFUNC mouse_func;
	PFNMOTIONFUNC motion_func;
	PFNPASSIVEMOTIONFUNC passive_motion_func;
	PFNIDLEFUNC idle_func;

} Window;

Window* create_window(const char* title, unsigned int width,unsigned int height,
	unsigned int x_pos, unsigned int y_pos, bool fullscreen);

void destroy_window(Window* window);

unsigned int get_window_height(Window* window);

unsigned int get_window_width(Window* window);

void set_window_size(Window* window, unsigned int width, unsigned int height);

unsigned int get_window_x_pos(Window* window);

unsigned int get_window_y_pos(Window* window);

void set_window_position(Window* window, unsigned int x_pos, unsigned int y_pos);

bool get_window_fullscreen(Window* window);

void set_window_fullscreen(Window* window, bool fullscreen);

void set_window_init_func(Window* window, PFNINITFUNC init_func);

void set_window_display_func(Window* window, PFNDISPLAYFUNC display_func);

void set_window_reshape_func(Window* window, PFNRESHAPEFUNC reshape_func);

void set_window_keyboard_func(Window* window, PFNKEYBOARDFUNC keyboard_func);

void set_window_keyboard_up_func(Window* window, PFNKEYBOARDUPFUNC keyboard_up_func);

void set_window_special_func(Window* window, PFNSPECIALFUNC special_func);

void set_window_special_up_func(Window* window, PFNSPECIALUPFUNC special_up_func);

void set_window_mouse_func(Window* window, PFNMOUSEFUNC mouse_func);

void set_window_passive_motion_func(Window* window, PFNPASSIVEMOTIONFUNC passive_motion_func);

void set_window_idle_func(Window* window, PFNIDLEFUNC idle_func);

void set_window_visible(Window* window, bool visible);

#endif
